package com.ins.asyncrequest.hselect;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

//import org.apache.coyote.http11.Http11Nio2Protocol;

public class Logining extends HttpServlet {

	private String user = "F";
	
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html; charset=UTF-8");
		response.setContentType("text/html");
		ServletContext sc = getServletContext();
		RequestDispatcher rd = null;
		String m = (String) request.getParameter("innumber");
		String inid =(String) request.getParameter("inid");
		
		// 消费用户
		if (m.equals("1")) {
			HttpSession session=request.getSession();
			session.setAttribute("inid", inid);
			session.setAttribute("usertype", "1");//消费用户判断标识
			session.setAttribute("user", user);//用户sesscion授权
			request.getRequestDispatcher("/WEB-INF/pages/userCenter3.jsp").forward(request,response);
			Writer writer = response.getWriter();
			return;
		}
		// 仪器管理人员
		if (m.equals("2")) {
			HttpSession session=request.getSession();
			session.setAttribute("inid", inid);
			session.setAttribute("usertype", "2");//仪器管理人员判断标识
			session.setAttribute("user", user);//用户sesscion授权
			request.getRequestDispatcher("/WEB-INF/pages/yiqixinxiweihu15.jsp").forward(request,response);
			Writer writer = response.getWriter();
			return;
		}
		// 机构
		if (m.equals("3")) {
			HttpSession session=request.getSession();
			session.setAttribute("inid", inid);
			session.setAttribute("usertype", "3");//机构判断标识
			session.setAttribute("user", user);//用户sesscion授权
			request.getRequestDispatcher("/WEB-INF/pages/ins28.jsp").forward(request,response);
			Writer writer = response.getWriter();
			return;
		}
		request.getRequestDispatcher("/login.jsp").forward(request, response);
		Writer writer = response.getWriter();
	}

}
